package com.qf.servlet;

import com.qf.entity.StuInfo;
import com.qf.service.Impl.StulnfoServiceImpl;
import com.qf.service.StulnfoService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author a1275872671
 * @version v1.0
 * @project guanqipeng
 * @package com.qf.servlet
 * @company
 * @date 2024/4/30 12:33
 */
@WebServlet("/editServlet")
public class editServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String id = request.getParameter("id");
        if (id==null||id.trim().equals("")){
            response.sendRedirect("xinxi.jsp");
        }
        StulnfoService stulnfoService=new StulnfoServiceImpl();
        StuInfo stuInfo=stulnfoService.findById(Integer.parseInt(id));
        request.setAttribute("stuInfo",stuInfo);
        request.getRequestDispatcher("/updata.jsp").forward(request,response);

    }
}
